<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Result extends CI_Controller {
	
	private $_data	=	array();
	
	public function __construct()
	{
		parent::__construct();
		$this->load->helper('xml');  
        $this->load->helper('text'); 
        $this->load->model(array('result_model')); 
	}
	
	public function index()
	{
		//$this->_data
		$this->_data['feed_title'] = 'MyWebsite.com'; // your website  
    	$this->_data['encoding'] = 'utf-8'; // the encoding  
       	$this->_data['feed_url'] = 'http://www.MyWebsite.com/feed'; // the url to your feed  
       	$this->_data['page_description'] = 'What my site is about comes here'; // some description  
       	$this->_data['page_language'] = 'en-en'; // the language  
       	$this->_data['creator_email'] = 'mail@me.com'; // your email  
       	//$this->_data['posts'] = $this->posts->getPosts(10);  
       	$data	=	$this->result_model->get_today();
       	//$data	=	json_encode($data);
       	//print_r($data);
       	$this->_data['data']	=	$data;
       	//$data	=	json_decode($data);
       	//print_r($data);
       	
		
		header("Content-Type: application/rss+xml"); // important!  
		$this->load->view('rss/index', $this->_data);
	}
	
	public function view()
	{
		$feed_url	=	"http://localhost/xoso_mobile/rss/result";
		$data	=	$this->getRss($feed_url);
		echo '<pre>';
		print_r($data);
	
	}
	
	public function getRss($rss_url)
	{
		$content = file_get_contents($rss_url);  
	    $x = new SimpleXmlElement($content); 

	    $arr	=	array();
	    foreach($x->channel->item as $v)
	    {
	    	$arr[]	=	json_decode($v->description);
	    }
	    
	    return($arr);
	}
	
	
	function getFeed($feed_url) 
	{  
	    $content = file_get_contents($feed_url);  
	    $x = new SimpleXmlElement($content);  
	  	$str = "";
	    $str .= "<ul>";  
	  
	    foreach($x->channel->item as $entry) {  
	        $str .= "<li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>";  
	    }  
	    $str .= "</ul>";  
	    return $str;
	}  
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */